package com.dianping.cat.consumer.storage.model.transform;
import com.dianping.cat.consumer.storage.model.entity.Domain;
import com.dianping.cat.consumer.storage.model.entity.Machine;
import com.dianping.cat.consumer.storage.model.entity.Operation;
import com.dianping.cat.consumer.storage.model.entity.Segment;
import com.dianping.cat.consumer.storage.model.entity.Sql;
import com.dianping.cat.consumer.storage.model.entity.StorageReport;
import java.util.ArrayList;
import java.util.List;

public class DefaultLinker implements ILinker {
  private boolean m_deferrable;

  public DefaultLinker(boolean deferrable) {
/*  15 */     this.m_deferedJobs = new ArrayList();


/*  18 */     this.m_deferrable = deferrable;
  }
  private List<Runnable> m_deferedJobs;
  public void finish() {
/*  22 */     for (Runnable job : this.m_deferedJobs) {
/*  23 */       job.run();
    }
  }


  public boolean onDomain(final Machine parent, final Domain domain) {
    if (this.m_deferrable) {
/*  30 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  33 */               parent.addDomain(domain);
            }
          });
    } else {
/*  37 */       parent.addDomain(domain);
    }

/*  40 */     return true;
  }


  public boolean onMachine(final StorageReport parent, final Machine machine) {
/*  45 */     if (this.m_deferrable) {
/*  46 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  49 */               parent.addMachine(machine);
            }
          });
    } else {
/*  53 */       parent.addMachine(machine);
    }

/*  56 */     return true;
  }


  public boolean onOperation(final Domain parent, final Operation operation) {
/*  61 */     if (this.m_deferrable) {
/*  62 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  65 */               parent.addOperation(operation);
            }
          });
    } else {
/*  69 */       parent.addOperation(operation);
    }

/*  72 */     return true;
  }


  public boolean onSegment(final Operation parent, final Segment segment) {
/*  77 */     if (this.m_deferrable) {
      this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  81 */               parent.addSegment(segment);
            }
          });
    } else {
/*  85 */       parent.addSegment(segment);
    }

/*  88 */     return true;
  }


  public boolean onSql(final Domain parent, final Sql sql) {
/*  93 */     if (this.m_deferrable) {
/*  94 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  97 */               parent.addSql(sql);
            }
          });
    } else {
/* 101 */       parent.addSql(sql);
    }

/* 104 */     return true;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/lib/cat-consumer-3.0.0.jar!/com/dianping/cat/consumer/storage/model/transform/DefaultLinker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */